package com.itheima.day06.myException.test2;

public class Test {
    public static void main(String[] args) {
        int[] arr = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        arr = null;
        try {
            printArr(arr);
        } catch(NullPointerException npe){
            System.out.println("数组不能为空");
        }

        System.out.println("张帆巨帅");
    }

    public static void printArr(int[] arr) {
        if(arr == null){
             throw new NullPointerException();
        }else{
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i] + " ");
            }
        }
    }
}
